Skip to content

Disallow inline given ... with .. #14207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nicolasstucki
Copy link
Contributor

Only allow inline given ... = ... as the desugaring of
inline given ... with .. is fundamentally incompatible with inline
definitions.

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Jan 5, 2022

One version that used to "work" is

trait Foo[T]:
  inline def bar: Unit

inline given FooInt: Foo[Int] with
  inline def bar: Unit = ()

but it generates exactly the same code as

trait Foo[T]:
  inline def bar: Unit

given FooInt: Foo[Int] with
  inline def bar: Unit = ()

in this case it is enough to know that the call are to FooInt.bar to be able to trigger the inlining.

Note: in this case the inline given is not inlining anything and the inline silently disappearing.

nicolasstucki added a commit to dotty-staging/protoquill that referenced this pull request Jan 5, 2022
Replace with `given .. with` as it generates the same code.
See scala/scala3#14207 (comment)
nicolasstucki added a commit to dotty-staging/protoquill that referenced this pull request Jan 5, 2022
Replace with `given .. with` as it generates the same code.
See scala/scala3#14207 (comment)
Only allow `inline given ... = ...` as the desugaring of
`inline given ... with ..` is fundamentally incompatible with inline
definitions.
@nicolasstucki
Copy link
Contributor Author

@deusaquilus this is another change that will affect protoquill. This change does not affect the semantics or generated code in any way.

See dotty-staging/protoquill@2381981

@nicolasstucki
Copy link
Contributor Author

@deusaquilus, if we go with #14284 you will not need to change your code.

@nicolasstucki nicolasstucki removed the request for review from odersky January 17, 2022 15:39
@nicolasstucki
Copy link
Contributor Author

Might be replaced with #14284

@deusaquilus
Copy link
Contributor

@deusaquilus, if we go with #14284 you will not need to change your code.

So as far as I see all the changes you've made to protoquill to support #14207 are in src/test/scala/io/getquill/examples which is basically just my code-samples area so changing those a bit is totally fine. I don't know anything about #14284 but it looks like all everything is compiling so it should also be fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inline given ... with not compiling properly
3 participants